import 'package:dio/dio.dart';
import 'package:rxdart/rxdart.dart';
import 'package:wanchong/bean/cat_group_entity.dart';
import 'package:wanchong/bean/cats_entity.dart';
import 'package:wanchong/bean/pet_info_entity.dart';
import 'package:wanchong/bean/success_entity.dart';
import 'package:wanchong/utils/http.dart';

const BASE_PET_INFO = "/v1/animal";

///宠物详情页面
PublishSubject<PetInfoEntity> getPetInfo<BaseResponse>(String id) {
  return Http.getInstance().get<PetInfoEntity>(
    BASE_PET_INFO + "/" + id,
  );
}

///宠物子分类
PublishSubject<CatsEntity> getCats<BaseResponse>(String id) {
  return Http.getInstance()
      .get<CatsEntity>("/v1/cats", params: FormData.from({"gid": id}));
}

///宠物主分类
PublishSubject<CatGroupEntity> getCatGroup<BaseResponse>() {
  return Http.getInstance().get<CatGroupEntity>(
    "/v1/cat_group",
  );
}

///添加宠物
PublishSubject<SuccessEntity> animal<BaseResponse>(
  String header,
  String nick,
  int birthday,
  int weight,
  String cat_id,
  String imgs,
  String cat_group_id,
  String sex,
  String love_id,
) {
  return Http.getInstance().post<SuccessEntity>("/v1/animal",
      params: FormData.from({
        'header': header,
        'nick': nick,
        'birthday': birthday,
        'weight': weight,
        'cat_id': cat_id,
        'imgs': imgs,
        'cat_group_id': cat_group_id,
        'sex': sex,
        'love_id': love_id,
      }));
}
///更改宠物某一属性
PublishSubject<SuccessEntity> saveAnimal<BaseResponse>(String id,FormData data) {
  return Http.getInstance().put<SuccessEntity>(
    "/v1/animal/"+id,
    params: data
  );
}